﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Data;
using System.Data;

namespace Client
{
    public class MainWindowViewModel
    {
        public ICollectionView UserList { get; private set; }
        public ICollectionView FileList { get; private set; }

        public MainWindowViewModel()
        {
        }

        public void displayUserList(DataTable userlist)
        {
            List<User> users = new List<User>();

            foreach (DataRow row in userlist.Rows)
            {
                User user = new User();
                user.username = row["USERID"].ToString();
                users.Add(user);
            }

            UserList = CollectionViewSource.GetDefaultView(users);
        }

        public void displayXFileList(DataTable xfilelist)
        {
            List<XFile> xfiles = new List<XFile>();

            foreach (DataRow row in xfilelist.Rows)
            {
                XFile xFile = new XFile();
                xFile.xfilename = row["FILENAME"].ToString();
                xfiles.Add(xFile);
            }

            FileList = CollectionViewSource.GetDefaultView(xfiles);
        }
    }
}
